package com.itheima.mapper;

import com.itheima.pojo.BorrowRecord;
import com.itheima.pojo.vo.BorrowRecordVo;
import org.apache.ibatis.annotations.*;
import java.util.List;


@Mapper
public interface BorrowRecordMapper {
    @Insert("insert into borrow_record(user_id, book_id, operator_id, status, borrow_time, return_time, expected_return_time,card_number)" +
            "values(#{userId},#{bookId},#{operatorId},#{status},#{borrowTime},#{returnTime},#{expectedReturnTime},#{cardNumber})")
    void add(BorrowRecord borrowRecord);

    // 修改接口方法，移除分页参数（分页参数由PageHelper处理）
    List<BorrowRecordVo> list(@Param("cardNumber") String cardNumber,
                              @Param("bookId") Integer bookId,
                              @Param("status") Integer status);

    @Delete("delete from borrow_record where id=#{id}")
    void delete(Integer id);

    @Update("update borrow_record set operator_id=#{operatorId}," +
            "status=#{status},return_time=#{returnTime}")
    void update(BorrowRecord borrowRecord);
    @Update("update borrow_record set status=1 ,return_time=now() where id=#{id}")
    void updateStatus(Integer id);
}
